<?php
class EKADBPDO extends PDO
{
	public function __construct($db, $user, $pwd)
	{
		parent::__construct($db, $user, $pwd);
		$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	}
	
	public function prepareEKADBPDO($sql, $classname, $array)
	{
		$statement = parent::prepare($sql);
		if(strpos(strtoupper($sql), 'SELECT') === 0) //"SELECT"
		{
			$statement->setFetchMode(PDO::FETCH_CLASS|PDO::FETCH_PROPS_LATE, $classname, $array);
		}
		
		if(strpos(strtoupper($sql), 'INSERT') === 0) //"INSERT"
		{
			$statement->setFetchMode(PDO::FETCH_CLASS|PDO::FETCH_PROPS_LATE, $classname, $array);
		}
		
		if(strpos(strtoupper($sql), 'UPDATE') === 0) //"UPDATE"
		{
			$statement->setFetchMode(PDO::FETCH_CLASS|PDO::FETCH_PROPS_LATE, $classname, $array);
		}
		
		if(strpos(strtoupper($sql), 'DELETE') === 0) //"DELETE"
		{
			$statement->setFetchMode(PDO::FETCH_CLASS|PDO::FETCH_PROPS_LATE, $classname, $array);
		}
		return $statement;
	}
}